<?php
/**
 * @version		0.2.0 joomla zmluvy $
 * @package		com_zjmluvy
 * @copyright	Copyright © 2011 - All rights reserved.
 * @license		GNU/GPL
 * @author    AdrianKo		
 * @website   http://code.google.com/p/joomla-zmluvy
 *
 *
 *1.3.2012
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

jimport( 'joomla.application.component.model' );
jimport( 'joomla.utilities.date' );
jimport( 'joomla.filesystem.file' );
jimport( 'joomla.filesystem.folder' );


class jzmluvyModelNastaveni extends Jmodel
{

  var $_data = null;
  
	function __construct(){
    
    $post = JRequest::get( 'post' );
		
		parent::__construct();
	}

	function &getData()
	{
		if ($this->_loadData())
		{

		}

		return $this->_data;
	}

	function _loadData()
	{
		// Lets load the content if it doesn't already exist
		if (empty($this->_data))
		{
			$query = 'SELECT *'
					. ' FROM #__jzmluvy_nastaveni'
					. ' WHERE id = 1'
					;
			$this->_db->setQuery($query);
			$this->_data = $this->_db->loadObject();

			return (boolean) $this->_data;
		}
		return true;
	}

	function store($data)
	{
		global $mainframe;

		$row =& JTable::getInstance('nastaveni', '');

		// Bind the form fields to the table
		if (!$row->bind($data)) {
			$this->setError($this->_db->getErrorMsg());
			return false;
		}
		// Make sure the data is valid
		if (!$row->check()) {
			$this->setError($row->getError());
			return false;
		}
    
		// Store the table to the database
		if (!$row->store(true)) {
			$this->setError($this->_db->getErrorMsg());
			return false;
		}
		
		return $row->id;
	}
  
  
}
?>